package com.ponhu.ea2.stockcenter.dto;

import com.ponhu.ea2.stockcenter.enums.ExchangeActionTypeEnum;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.experimental.Accessors;

import java.io.Serializable;
import java.time.LocalDateTime;
import java.util.List;

/**
 * 对接WMS系统事件信息DTO
 */
@Data
@Accessors(chain = true)
@ApiModel(value = "对接WMS系统事件信息DTO")
public class WMSEventInfoDTO implements Serializable {

    /**
     * 调拨单号
     */
    @ApiModelProperty(value = "调拨单号")
    private String transferNo;

    /**
     * 业务单号
     */
    @ApiModelProperty(value = "业务单号")
    private String docNo;

    /**
     * 动作类型
     */
    @ApiModelProperty(value = "动作类型")
    private ExchangeActionTypeEnum actionType;

    /**
     * 调入仓库编码(例：采购入库的仓库，记录在这个属性上)
     */
    @ApiModelProperty(value = "调入仓库编码")
    private String inWarehouseCode;

    /**
     * 调出仓库编码(例：销售出库的仓库，记录在这个属性上)
     */
    @ApiModelProperty(value = "调出仓库编码")
    private String outWarehouseCode;

    /**
     * 调入仓库是否可售
     */
    @ApiModelProperty(value = "调入仓库是否可售")
    private Boolean inWarehouseIsSale;

    /**
     * 调出仓库是否可售
     */
    @ApiModelProperty(value = "调出仓库是否可售")
    private Boolean outWarehouseIsSale;

    /**
     * 货品信息列表
     */
    @ApiModelProperty(value = "货品信息列表")
    private List<WMSInventoryInfo> inventoryInfoList;

    @ApiModelProperty(value = "批次操作时间")
    private LocalDateTime operatorTime;

    @ApiModelProperty(value = "批次操作人")
    private String operatorName;

    /**
     * 处理次数：默认 1 次，大于 1 次表示 Redis 缓存处理
     */
    @ApiModelProperty(value = "处理次数", hidden = true)
    private Integer frequency = 1;

    public Boolean isFirstFrequency() {
        return this.frequency == 1;
    }

    public WMSEventInfoDTO addFrequency() {
        this.frequency += 1;
        return this;
    }

}
